package cn.cloudreal.cbms.medium.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLDecoder;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;

import cn.cloudreal.cbms.Dictionary.service.DictionaryService;
import cn.cloudreal.cbms.common.util.DatadicContext;
import cn.cloudreal.cbms.common.util.PageBean;
import cn.cloudreal.cbms.log.service.OptLogService;
import cn.cloudreal.cbms.mediaPrice.service.MediaPriceService;
import cn.cloudreal.cbms.mediasumm.service.MediasummService;
import cn.cloudreal.cbms.medium.service.MediumService;
import cn.cloudreal.cbms.vo.Dictionary;
import cn.cloudreal.cbms.vo.Log;
import cn.cloudreal.cbms.vo.MediaPrice;
import cn.cloudreal.cbms.vo.Mediasumm;
import cn.cloudreal.cbms.vo.Medium;
import cn.cloudreal.cbms.vo.ProjectMedium;
import cn.cloudreal.cbms.vo.UserInfo;

import com.opensymphony.xwork2.ActionSupport;

public class MediumAction extends ActionSupport
{

    private OptLogService optLogService = null; // 日志的service
    private List<Log> logList = null;// 列表显示详情日志
    private MediumService mediumService = null; // 媒介service
    private MediasummService mediasummService = null;// 媒体service
    private DictionaryService dictionaryService = null;// 数据字典Service
    private MediaPriceService mediaPriceService = null;//媒体价格Service
    /** 当前页 */
    private int currentPage;

    /** 分页对象 */
    private PageBean page;
    /** 日志工具类实例 */

    private List<Medium> mList = null; // 媒介list
    private int mediaID = 0; // 媒体编号
    private String mediumID = "";// 媒介编号
    private String mediumName = "";// 媒介名称
    private int id = 0;// id
    private Medium medium = null;// 媒介类
    private List<Mediasumm> msList = null; // 媒体类
    private String mediaName = "";
    private String contractYear = "";// 年度
    private String nowDate = "";// 当前日期
    private List<Dictionary> mediumPromotionTypeList = null;// 媒介赠送类型
    private List<Dictionary> mediaTypeList = null;// 媒体类型
    private List<Dictionary> shuXingList = null;// 媒介属性List
    private List<Dictionary> citylist = new ArrayList<Dictionary>();// 地区list
    private String message = "";// 返回内容
    private String msg = "";
    private int priceID = 0;// 媒体价格ID
    private int falg = 0;// 添加媒介状态
    private String mediaType = "";// 媒体类型KEY
    private String mediaType1 = "";// 媒体类型
    private int maxValue = 0;//排期最大值
    private List mediumList = null;
    private int mediumListSize=0;//媒介扩展属性个数
    // private MediaPrice mediaPrice = null;//媒体价格实体

    private static final Logger log = Logger.getLogger(MediumAction.class);

    /**
     * 媒介分页查询
     * 
     * @return
     */
    public String findMediumList()
    {
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction findMediumList() method, return String");
        }
        try
        {
//            System.out.println(priceID);
            List<MediaPrice> list = mediaPriceService.findMediaPriceByPriceID(priceID);//.findMediaPriceByMediaIDOrName(mediaID, "","",null);
            mediaTypeList = DatadicContext.getInstance().getDicDataListByCode("MTLX");// 媒体类型
            if(list == null || list.size() ==0){
                return "error_01";
            }
            // 实例化 page分页对象
            Medium medium = new Medium();
            medium.setMediaID(mediaID);// 媒体编号
            medium.setMediumID(mediumID);// 媒介编号
            medium.setMediumName(mediumName);// 媒介名称
            medium.setPriceID(priceID);
            page = new PageBean(currentPage == 0 ? 1 : currentPage, 10);
//            mList = mediumService.findMediumList(page, medium);
            
            Dictionary dic = new Dictionary();
            dic.setParentid(mediaType1);
            dic.setClasscode("MJZDPZ");
            shuXingList = dictionaryService.findAll(dic);// 媒介属性LIst
            String key ="";
            String keySql="";
            for(int i=0;i<shuXingList.size();i++){
                if(shuXingList.get(i).getId()!=null && !"".equals(shuXingList.get(i).getId())){
                    key += ","+shuXingList.get(i).getId();
                }
            }
            for(int i=0;i<shuXingList.size();i++){
                if(shuXingList.get(i).getId()!=null && !"".equals(shuXingList.get(i).getId())){
                    keySql += ",a."+shuXingList.get(i).getId()+" as "+shuXingList.get(i).getId();
                }
            }
            System.out.println(key);
            System.out.println(keySql);
            medium.setExtAttribute01(key);
            medium.setExtAttribute02(keySql);
            if(shuXingList != null){
                mediumListSize = shuXingList.size();//媒介扩展属性个数
            }
            for (int i = 0; i < mediaTypeList.size(); i++) {
                if(mediaType1.equals(mediaTypeList.get(i).getId())){
                    medium.setExtAttribute03(mediaTypeList.get(i).getDatavalue());//媒体类型
                    break;
                }
            }
            System.out.println(key);
            System.out.println(keySql);
            
            mediumList = mediumService.findMediumList(page, medium);//mediumService.findAllMedium(page, medium, key,keySql);
            mediumPromotionTypeList = DatadicContext.getInstance().getDicDataListByCode("MJZSLX"); // 媒介赠送类型List
            
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return ERROR;
        }
        // 结束打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction findMediumList() method, return String");
        }
        return SUCCESS;
    }

    /**
     * 媒介删除
     * 
     * @return
     */
    public String delMedium()
    {
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction delMedium() method, return String");
        }
        try
        {
            List<ProjectMedium> list = mediumService.findProjectmediumByMediumId(id);
            if(list != null && list.size()!=0){
                message = "error";
            }else{
                mediumService.delMedium(id);
                message = "success";
            }
        }
        catch (Exception e)
        {
//            message = "error";
            return ERROR;
        }
        this.findLogMessage("删除了", "刊例,刊例ID："+id, "T_CB_MEDIUM", String.valueOf(id));
        // 结束打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction delMedium() method, return String");
        }
        return SUCCESS;
    }

    /**
     * 跳转到媒介页面
     * 
     * @return
     */
    public String toAddMedium()
    {
        // msList = mediasummService.findAllMediasumm(null);//查找媒体
        // List<MediaPrice> mpList =
        // mediaPriceService.findAllMediaPriceByPriceID(priceID);
        // if(mpList!= null && mpList.size()!=0){
        // mediaPrice = mpList.get(0);
        // }
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction toAddMedium() method, return String");
        }
        try
        {
            msg = "";// 清空message
            nowDate = this.getNowDateTime();// 当前时间
            mediaTypeList = DatadicContext.getInstance().getDicDataListByCode("MTLX");// 媒体类型
            mediumPromotionTypeList = DatadicContext.getInstance().getDicDataListByCode("MJZSLX"); // 媒介赠送类型List
            Dictionary dic = new Dictionary();
            dic.setParentid(mediaType1);
            dic.setClasscode("MJZDPZ");
            dic.setExtAttr2_01("order_by");// 用于排序
            shuXingList = dictionaryService.findAll(dic);// 媒介属性LIst
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return ERROR;
        }
        // 结束打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction toAddMedium() method, return String");
        }
        return SUCCESS;
    }

    /**
     * 根据媒体名查询媒体
     * 
     * @return
     */
    public String findMediasummByName_01()
    {
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction findMediasummByName_01() method, return String");
        }
        try
        {
            Mediasumm mediasumm1 = new Mediasumm();
            mediasumm1.setMediaName(mediaName);
            msList = mediasummService.findAllMediasumm(mediasumm1); // 查找媒体
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return ERROR;
        }
        // 结束打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction findMediasummByName_01() method, return String");
        }
        return SUCCESS;
    }

    /**
     * 根据媒介编号查询
     * 
     * @return
     */
    public String findMediumByMediumID()
    {
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction findMediumByMediumID() method, return String");
        }
        try
        {
            List<Medium> mList = mediumService.findMediumByMediumID(mediumID);
            if (!"".equals(mediumID.trim()))
            {
                if (mList != null && mList.size() != 0)
                {
                    message = "error";
                }
                else
                {
                    message = "success";
                }
            }
            else
            {
                message = "error";
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return ERROR;
        }
        // 结束打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction findMediumByMediumID() method, return String");
        }
        return SUCCESS;
    }

    /**
     * 查找所有属性
     * 
     * @return
     */
    public String findMediumShuXing()
    {
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction findMediumShuXing() method, return String");
        }
        try
        {
            Dictionary dic = new Dictionary();
            dic.setParentid(mediaType);
            dic.setClasscode("MJZDPZ");
            shuXingList = dictionaryService.findAll(dic);// 媒介属性LIst
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return ERROR;
        }
        // 结束打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction findMediumShuXing() method, return String");
        }
        // shuXingList =
        // DatadicContext.getInstance().getSubDatadicByCode(mediaType,"MJZDPZ");//媒介属性List
        return SUCCESS;
    }

    /**
     * 根据媒介名查找媒介
     * 
     * @return
     */
    public String findMediumByMediumName()
    {
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction findMediumByMediumName() method, return String");
        }
        try
        {
            String mediumName1 = URLDecoder.decode(mediumName.trim(),"UTF-8");
            List<Medium> mList = mediumService.findMediumByMediumName(mediumName1);
            if (!"".equals(mediumName1.trim()))
            {
                if (mList != null && mList.size() != 0)
                {
                    message = "error";
                }
                else
                {
                    message = "success";
                }
            }
            else
            {
                message = "error";
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return ERROR;
        }

        // 结束打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction findMediumByMediumName() method, return String");
        }
        return SUCCESS;
    }

    /**
     * 添加媒介
     * 
     * @return
     */
    public String doAddMedium()
    {
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction doAddMedium() method, return String");
        }
        int num = 0;// 插入返回的ID
        // 日历
        Calendar c = Calendar.getInstance();
        c.clear();
        // 设置年度
        c.set(Calendar.YEAR, (Integer.parseInt(medium.getContractYear()) + 1900));
        // 初始化
        StringBuffer sb = new StringBuffer();
        // 循环
        for (int i = 0; i < c.getActualMaximum(Calendar.DAY_OF_YEAR); i++)
        {
            sb.append("," + 0);
        }
       
            if (falg == 2)
            {
                SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                Date date = new Date();
                String nowTime = sf.format(date);
                medium.setModifyTime(nowTime);
                if("".equals(medium.getSurchargesRatio()) || medium.getSurchargesRatio() == null){
                    medium.setSurchargesRatio(0.0);
                }
                System.out.println(sb.toString());
                medium.setMediumArrangement(sb.toString().substring(1));
                try
                {
                    num = mediumService.addMedium(medium);
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                    return ERROR;
                }
                this.findLogMessage("新增了", "刊例", "T_CB_MEDIUM", String.valueOf(num));
                this.alertMessage("刊例新增成功", "toAddMediumAction.action?priceID=" + priceID + "&mediaID=" + mediaID
                        + "&mediaType1=" + mediaType1 + "&contractYear=" + contractYear);
            }
            if (falg == 1)
            {
                    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    Date date = new Date();
                    String nowTime = sf.format(date);
                    medium.setModifyTime(nowTime);
                    System.out.println( sb.toString());
                    medium.setMediumArrangement(sb.toString().substring(1));
                    try
                    {
                        num = mediumService.addMedium(medium);
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                        return ERROR;
                    }
                    mediumID = "";// 清空媒介ID
                    mediumName = "";// 清空媒介名字
                    this.findLogMessage("新增了", "刊例", "T_CB_MEDIUM", String.valueOf(num));
                    this.alertMessage("刊例新增成功", "mediumAction.action?priceID=" + medium.getPriceID() + "&mediaID="
                            + medium.getMediaID() + "&mediaType1=" + medium.getMediaType() + "&contractYear="
                            + medium.getContractYear());
                
        }
        
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction doAddMedium() method, return String");
        }
        return null;
    }

    // public void validateDoAddMedium(){
    // if(medium.getMediumPrice()>0){
    // this.addFieldError("medium.mediumPrice", "刊例价格格式错误");
    // System.out.println("asdfasdfadsf");
    // this.toAddMedium();
    // }
    // }
    //    

    /**
     * 跳转到媒介修改页码
     * 
     * @return
     */
    public String toUpdateMedium()
    {
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction toUpdateMedium() method, return String");
        }
        try
        {
            medium = mediumService.findMediumById(id); // 查找媒介
            if(medium ==null){
                return "error_01";
            }
            //.getMediumAbility();
             String [] arr = medium.getMediumArrangement().split(",");
             for (int i = 0; i < arr.length; i++)
            {
                if(Integer.parseInt(arr[i])>=maxValue){
                    maxValue = Integer.parseInt(arr[i]);
                }
            }
            
            mediaTypeList = DatadicContext.getInstance().getDicDataListByCode("MTLX");// 媒体类型
            mediumPromotionTypeList = DatadicContext.getInstance().getDicDataListByCode("MJZSLX"); // 媒介赠送类型List
            Dictionary dic = new Dictionary();
            dic.setParentid(medium.getMediaType());
            dic.setClasscode("MJZDPZ");
            dic.setExtAttr2_01("order_by");// 用于排序
            shuXingList = dictionaryService.findAll(dic);// 媒介属性LIst

        }
        catch (Exception e)
        {
            e.printStackTrace();
            return ERROR;
        }
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction toUpdateMedium() method, return String");
        }
        return SUCCESS;
    }

    /**
     * 修改媒介
     * 
     * @return
     */
    public String doUpdateMedium()
    {
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction doUpdateMedium() method, return String");
        }
        Medium medium1 = null;
        try
        {
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date();
            String nowTime = sf.format(date);
            if("".equals(medium.getSurchargesRatio()) || medium.getSurchargesRatio() == null){
                medium.setSurchargesRatio(0.0);
            }
            medium.setModifyTime(nowTime);
            int num = mediumService.udpateMedium(medium);
            medium1 = mediumService.findMediumById(medium.getId()); // 查找媒介
            mediumID = "";
            mediumName = "";
            if(num == 0){
                return "error_01";
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return ERROR;
        }
        // 详情日志
        this.findLogMessage("编辑了", "刊例", "T_CB_MEDIUM", String.valueOf(medium.getId()));
        this.alertMessage("刊例修改成功", "mediumAction.action?mediaID=" + medium.getMediaID() + "&priceID=" + medium1.getPriceID()
                + "&mediaType1=" + medium1.getMediaType() + "&contractYear=" + medium1.getContractYear());
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction doUpdateMedium() method, return String");
        }
        return null;
    }

    /**
     * 媒介详情
     */
    public String toMediumDetails()
    {
        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Enter MediumAction toMediumDetails() method, return String");
        }
        try
        {
            medium = mediumService.findMediumById(id);
            if(medium ==null){
                return "error_01";
            }
            mediaTypeList = DatadicContext.getInstance().getDicDataListByCode("MTLX");// 媒体类型
            mediumPromotionTypeList = DatadicContext.getInstance().getDicDataListByCode("MJZSLX"); // 媒介赠送类型List
            Dictionary dic = new Dictionary();
            dic.setParentid(medium.getMediaType());
            dic.setClasscode("MJZDPZ");
            dic.setExtAttr2_01("order_by");// 用于排序
            shuXingList = dictionaryService.findAll(dic);// 媒介属性LIst

            // 日志详情
            Log sample = new Log();
            sample.setRelationId(String.valueOf(medium.getId()));
            sample.setLogType("T_CB_MEDIUM");
            logList = new ArrayList<Log>();
            logList = optLogService.getLogsBySample(sample);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return ERROR;
        }

        // 开始打印日志
        if (log.isInfoEnabled())
        {
            log.info("Exit MediumAction toMediumDetails() method, return String");
        }
        return SUCCESS;
    }

    // 获取日志
    public void findLogMessage(String addOrUpdateMsg, String typeName, String tableName, String tableID)
    {
        // 日志记录
        UserInfo userSession = (UserInfo) ServletActionContext.getRequest().getSession().getAttribute("logUser");
        String user = null;
        String cityCode = null;
        String cityName = null;
        String organizaOragName = null;
        if (null == userSession)
        {
            user = "张三";
            cityName = "东莞";
            organizaOragName = "市场部";
            cityCode = "DG";
        }
        else
        {
            user = userSession.getUserName();
            cityCode = userSession.getUsercity();
            cityName = userSession.getCityName();
            organizaOragName = userSession.getOrganiza().getOrgName();
        }
        if (null == cityCode)
        {
            cityCode = "";
            cityName = "东莞";
        }
        Timestamp d = new Timestamp(System.currentTimeMillis());
        String content = d + " " + cityName + organizaOragName + user + addOrUpdateMsg + typeName;
        String datatime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
        // System.out.println("data======"+data);
        /** 获取变更记录的数据 */
        Log logRecord = new Log(tableName, content, tableID, datatime, user, cityCode, organizaOragName, "");
        optLogService.addLog(logRecord);
    }

    /**
     * 当前年月日
     * 
     * @return
     */
    public String getNowDateTime()
    {
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = new Date();
        return sf.format(date);// 当前时间
    }

    public List<Mediasumm> getMsList()
    {
        return msList;
    }

    public void setMsList(List<Mediasumm> msList)
    {
        this.msList = msList;
    }

    public void setMediasummService(MediasummService mediasummService)
    {
        this.mediasummService = mediasummService;
    }

    public void setMediumService(MediumService mediumService)
    {
        this.mediumService = mediumService;
    }

    public int getCurrentPage()
    {
        return currentPage;
    }

    public void setCurrentPage(int currentPage)
    {
        this.currentPage = currentPage;
    }

    public PageBean getPage()
    {
        return page;
    }

    public void setPage(PageBean page)
    {
        this.page = page;
    }

    public List<Medium> getMList()
    {
        return mList;
    }

    public void setMList(List<Medium> list)
    {
        mList = list;
    }

    public int getMediaID()
    {
        return mediaID;
    }

    public void setMediaID(int mediaID)
    {
        this.mediaID = mediaID;
    }

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public Medium getMedium()
    {
        return medium;
    }

    public void setMedium(Medium medium)
    {
        this.medium = medium;
    }

    public String getMediaName()
    {
        return mediaName;
    }

    public void setMediaName(String mediaName)
    {
        this.mediaName = mediaName;
    }

    public String getContractYear()
    {
        return contractYear;
    }

    public void setContractYear(String contractYear)
    {
        this.contractYear = contractYear;
    }

    public List<Dictionary> getMediumPromotionTypeList()
    {
        return mediumPromotionTypeList;
    }

    public void setMediumPromotionTypeList(List<Dictionary> mediumPromotionTypeList)
    {
        this.mediumPromotionTypeList = mediumPromotionTypeList;
    }

    public String getNowDate()
    {
        return nowDate;
    }

    public void setNowDate(String nowDate)
    {
        this.nowDate = nowDate;
    }

    public String getMessage()
    {
        return message;
    }

    public void setMessage(String message)
    {
        this.message = message;
    }

    public String getMediumID()
    {
        return mediumID;
    }

    public void setMediumID(String mediumID)
    {
        this.mediumID = mediumID;
    }

    public String getMediumName()
    {
        return mediumName;
    }

    public void setMediumName(String mediumName)
    {
        this.mediumName = mediumName;
    }

    public int getPriceID()
    {
        return priceID;
    }

    public void setPriceID(int priceID)
    {
        this.priceID = priceID;
    }

    public int getFalg()
    {
        return falg;
    }

    public void setFalg(int falg)
    {
        this.falg = falg;
    }

    public String getMsg()
    {
        return msg;
    }

    public void setMsg(String msg)
    {
        this.msg = msg;
    }

    public List<Dictionary> getMediaTypeList()
    {
        return mediaTypeList;
    }

    public void setMediaTypeList(List<Dictionary> mediaTypeList)
    {
        this.mediaTypeList = mediaTypeList;
    }

    public String getMediaType()
    {
        return mediaType;
    }

    public void setMediaType(String mediaType)
    {
        this.mediaType = mediaType;
    }

    public List<Dictionary> getShuXingList()
    {
        return shuXingList;
    }

    public void setShuXingList(List<Dictionary> shuXingList)
    {
        this.shuXingList = shuXingList;
    }

    public void setDictionaryService(DictionaryService dictionaryService)
    {
        this.dictionaryService = dictionaryService;
    }

    public String getMediaType1()
    {
        return mediaType1;
    }

    public void setMediaType1(String mediaType1)
    {
        this.mediaType1 = mediaType1;
    }

    public List<Log> getLogList()
    {
        return logList;
    }

    public void setLogList(List<Log> logList)
    {
        this.logList = logList;
    }

    public void setOptLogService(OptLogService optLogService)
    {
        this.optLogService = optLogService;
    }

    public void setMediaPriceService(MediaPriceService mediaPriceService)
    {
        this.mediaPriceService = mediaPriceService;
    }
    
    public List<Dictionary> getCitylist()
    {
        return citylist;
    }

    public void setCitylist(List<Dictionary> citylist)
    {
        this.citylist = citylist;
    }

    public List getMediumList() {
        return mediumList;
    }

    public void setMediumList(List mediumList) {
        this.mediumList = mediumList;
    }
    
    public int getMediumListSize() {
        return mediumListSize;
    }

    public void setMediumListSize(int mediumListSize) {
        this.mediumListSize = mediumListSize;
    }

    public static void main(String[] args)
    {
        String str = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,15,15,15,15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,0,0,0,0,0,0,0,0,0,0,0,0";
        String [] arr = str.split(",");
        int maxValue = 0;
        for (int i = 0; i < arr.length; i++)
       {
           if(Integer.parseInt(arr[i])>=maxValue){
               maxValue = Integer.parseInt(arr[i]);
           }
       }
        System.out.println(maxValue);
    }

    
    
    public int getMaxValue()
    {
        return maxValue;
    }

    public void setMaxValue(int maxValue)
    {
        this.maxValue = maxValue;
    }

    /**
     * 弹出提示信息
     */
    private void alertMessage(String message, String url)
    {
        try
        {
            HttpServletResponse response = ServletActionContext.getResponse();
            response.setCharacterEncoding("UTF-8");
            response.setContentType("text/html; charset=utf-8");
            PrintWriter out = response.getWriter();
            out = response.getWriter();
            out.println(" <script type='text/javascript' >");
            out.println("alert('" + message + "');");
            out.println("location='" + url + "'");
            out.println(" </script>");
            out.flush();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }
}
